#include<bits/stdc++.h>
using namespace std;
int T,n,m,l,v1;
struct car{
    int d,v,a;//weizhi,chusu,jiasudu
}c[100006];
int flagA,flagB,flagC,p[100005];
int dd(int v,int a,int d){
    return int(sqrt(v*v+2*a*(l-d)));
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>T;
    while(T--){
        flagA=1,flagB=1,flagC=1;
        cin>>n>>m>>l>>v1;
        int maxx=-100;
        for(int i=1;i<=n;i++){
            cin>>c[i].d>>c[i].v>>c[i].a;
            maxx=max(maxx,c[i].v);
            if(c[i].a>0){
                maxx=max(maxx,dd(c[i].v,c[i].a,c[i].d));
            }
            if(c[i].a<0){
                flagA=0,flagB=0;
            }else{
                flagA=0,flagC=0;
            }
        }for(int i=1;i<=m;i++){
            cin>>p[i];
        }sort(p+1,p+m+1);
        if(maxx<=v1){cout<<0<<" "<<m<<endl;continue;}
        if(flagA||flagB){
            if(flagA){
                int ans=0;
                for(int i=1;i<=n;i++)
                    if(c[i].v>v1&&c[i].d<=p[m])ans++;
                cout<<ans<<" ";
            }else if(flagB){
                int ans=0;
                for(int i=1;i<=n;i++)
                    if(c[i].d<=p[m]){
                        if(sqrt(c[i].v*c[i].v+2*c[i].a*(p[m]-c[i].d))>v1)ans++;
                    }
                cout<<ans<<" ";
            }
            cout<<m-1<<endl;continue;
        }
        if(flagC){

        }
    }

    return 0;
}
